/*
 * @Descripttion:
 * @version:
 * @Author: cpy
 * @Date: 2023-10-11 16:10:00
 */
#ifndef __CS5463_H
#define __CS5463_H
#include "sys.h"

#define CONFG_CMD 0x40
#define POWER_0N_CMD 0xA0
#define STATER_GET_CMD 0x5E
#define ADC_NUM_SET_CMD 0x4A
#define INTE_DISEN_CMD 0x74
#define MODE_SET_CMD 0x64
#define CTAL_CMD 0x78
#define PULSE_RATE_CMD 0x4C
#define START_ADC_CMD 0xE8
#define VOLT_OFF_CMD 0x64
#define CTAL_CMD 0x78
#define PULSE_RATE_CMD 0x4C
#define START_ADC_CMD 0xE8
#define CURR_RMS_CMD 0x56
#define CURR_PEAK_CMD 0x6C
#define VOLT_RMS_CMD 0x58
#define PACTIVE_CMD 0x54
#define PF_FACT_CMD 0x72
#define VOLT_OFFSET_CMD 0x46
#define VOLT_GAIN_CMD 0x48
#define CURR_OFFSET_CMD 0x42
#define CURR_GAIN_CMD 0x44

#define DCVOLT_OFFSET 0X3EB8EE
#define DCVOLT_GAIN 0X5453B

typedef struct CSCorrect
{
	u8 Correct_Falg;
	u8 Correct_Cmd_Type;
	u32 Para_Data_Value;
} sCSCorrect;
extern sCSCorrect CSCorrect;

typedef enum CSCorrectType
{
	CMD_VOLT_OFFSET = 0xA1,
	CMD_VOLT_GAIN = 0xA2,
	CMD_VOLT_RANGE = 0xA3,
	CMD_CURR_OFFSET = 0xB1,
	CMD_CURR_GAIN = 0xB2,
	CMD_CURR_RANGE = 0xB3,
	CMD_PARA_EEPROM = 0xC1,
} sCSCorrectType;

/*
typedef enum  CSCmd
{


}sCSCmd;
*/

typedef struct CSdata
{
	u32 Ipeak;
	u32 Irms;
	u32 Vrms;
	u32 Pactive;
	u32 PF;
	u32 Config;

	u32 Idcoff;
	u32 Ign;
	u32 Iacoff;
	u32 Vdcoff;
	u32 Vgn;
	u32 Vacoff;
} sCSdata;
extern sCSdata CSdata_Type;

u8 CSpara_Init(void);
u8 CSpara_GetAll(void);
u8 CSpara_Calcustiom(void);
u8 CSpara_Correct_Write(void);
u8 CSpara_Correct_Send(void);
void Sys_Calibration(void);

#endif
